


import { userInfo } from '@/api/index.js'

const state = {
  "avatar": "",
  "identity": "",
  "level": 0,
  "direct_count": 0,
  "direct_bonus": 0,
  "assets": {
    "user_id": 0,
    "coin": "",
    "amount": 0,
    "bonus": 0
  },
  "share_link": "",
  "share_code": ""
}
const mutations = {
  setUserInfo(state, data) {
    state.avatar = data.avatar;
    state.identity = data.identity;
    state.level = data.level;
    state.direct_count = data.direct_count;
    state.direct_bonus = data.direct_bonus;
    state.assets = data.assets;
    state.share_link = data.share_link;
    state.share_code = data.share_code;
  },
}
const actions = {
  async getUserInfo(state, data) {
    let res = await userInfo();
    if (res.code == '200') this.commit('m_userInfo/setUserInfo', res.data);
  }
}
export default {
  namespaced: true,
  state,
  mutations,
  actions
}